using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TestJava : MonoBehaviour
{
#if UNITY_ANDROID && !UNITY_EDITOR
    class AndroidUnityCallback : AndroidJavaProxy
    {
        public AndroidUnityCallback() : base("com.example.android.UnityCallback")
        {}

        public void Callback(int a, string b) {
            Debug.LogError("callbacked from java: " + a + " | " + b);
        }
    }


    void Start()
    {
        {
            AndroidJavaClass ajc = new AndroidJavaClass("com.unity_test_java.JavaSDK");
            int a = ajc.CallStatic<int>("TestStaticMethod");
            Debug.LogError("test java static method return: " + a);
        }
        
        {
            AndroidJavaObject ajo = new AndroidJavaObject("com.unity_test_java.JavaSDK");
            int a = ajo.Call<int>("TestJavaInt", 123);
            Debug.LogError("test java int  " + a);

            string b = ajo.Call<string>("TestJavaString", "this is a c# string");
            Debug.LogError("test java string  " + b);

            ajo.Call("TestJavaCallCS", new AndroidUnityCallback());
        }
    }
#endif
}
